<html>
<head><meta charset="utf-8"><title>Const generics math tracking issue · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html">Const generics math tracking issue</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209380458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209380458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209380458">(Sep 08 2020 at 12:45)</a>:</h4>
<p>What is the tracking issue for being able to do basic math with const generics?</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">x</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span>: <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="o">-</span><span class="mi">4</span><span class="p">]</span><span class="w"></span>
</code></pre></div>



<a name="209380543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209380543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209380543">(Sep 08 2020 at 12:46)</a>:</h4>
<p>what is that supposed to do?</p>



<a name="209380722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209380722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209380722">(Sep 08 2020 at 12:48)</a>:</h4>
<p>(to be precise: how does type checking <code>x</code> in general work if some monomorphizations are not well typed?)</p>



<a name="209380797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209380797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209380797">(Sep 08 2020 at 12:49)</a>:</h4>
<p>implicitly: const equality and const well-formedness related issues. <a href="https://github.com/rust-lang/compiler-team/issues/340">https://github.com/rust-lang/compiler-team/issues/340</a></p>



<a name="209382895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209382895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209382895">(Sep 08 2020 at 13:06)</a>:</h4>
<p>I wonder if it's <a href="https://github.com/rust-lang/rust/issues/68436">https://github.com/rust-lang/rust/issues/68436</a></p>



<a name="209383001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383001">(Sep 08 2020 at 13:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue/near/209380543">said</a>:</p>
<blockquote>
<p>what is that supposed to do?</p>
</blockquote>
<p>The more specific example:</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">read_u16_le</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="n">data</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="p">(</span><span class="kt">u16</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">2</span><span class="p">])</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">todo</span><span class="o">!</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="209383105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383105">(Sep 08 2020 at 13:08)</a>:</h4>
<p>how should it behave for N=1 or N=0 I think is the question</p>



<a name="209383131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383131">(Sep 08 2020 at 13:08)</a>:</h4>
<p>SFINAE doesn't sound like something I want to add to rust <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="209383135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383135">(Sep 08 2020 at 13:08)</a>:</h4>
<p>so it'd split off 2 bytes of the input, convert them to a <code>u16</code>, then return that and the remainder. It's a common request when parsing binary data.</p>



<a name="209383165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383165">(Sep 08 2020 at 13:08)</a>:</h4>
<p>absolutely. There'd have to be appropriate bounds.</p>



<a name="209383340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383340">(Sep 08 2020 at 13:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue/near/209383105">said</a>:</p>
<blockquote>
<p>how should it behave for N=1 or N=0 I think is the question</p>
</blockquote>
<p>And this is what the compiler says today:</p>
<div class="codehilite"><pre><span></span><code>error: constant expression depends on a generic parameter
 --&gt; src/lib.rs:3:51
  |
3 | fn read_u16_le&lt;const N: usize&gt;(data: &amp;[u8; N]) -&gt; (u16, &amp;[u8; N - 2]) {
  |                                                   ^^^^^^^^^^^^^^^^^^^
  |
  = note: this may fail depending on what value the parameter takes
</code></pre></div>



<a name="209383395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383395">(Sep 08 2020 at 13:10)</a>:</h4>
<p>Although it seems like the <code>^^^</code> should be a bit smaller area</p>



<a name="209383846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383846">(Sep 08 2020 at 13:14)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[();</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span>:
<span class="p">{</span><span class="w"></span>
</code></pre></div>


<p>Well that just <em>looks</em> wrong.</p>



<a name="209383878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383878">(Sep 08 2020 at 13:14)</a>:</h4>
<p>(<a href="https://hackmd.io/OZG_XiLFRs2Xmw5s39jRzA?view">https://hackmd.io/OZG_XiLFRs2Xmw5s39jRzA?view</a>)</p>



<a name="209383903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209383903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209383903">(Sep 08 2020 at 13:15)</a>:</h4>
<p>I think there was some discussion of <code>where {N &gt; 1}</code>? not sure where though</p>



<a name="209384167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209384167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209384167">(Sep 08 2020 at 13:16)</a>:</h4>
<blockquote>
<p>We currently use where [(); expr]: as a way to add additional const wf bounds.<br>
Once we have started experimenting with this it is probably worth it to add<br>
a more intuitive way to add const wf bounds.</p>
<p>A possible syntax is where (expr),. This is not intended to be part of the<br>
initial unstable implementation however.</p>
</blockquote>



<a name="209384337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209384337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209384337">(Sep 08 2020 at 13:18)</a>:</h4>
<p>I guess that is parsed as valid syntax right now. Isn't implemented in nightly though.</p>



<a name="209398177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209398177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209398177">(Sep 08 2020 at 14:57)</a>:</h4>
<p>you already found the hackmd, here's the relevant compiler mcp: <a href="https://github.com/rust-lang/compiler-team/issues/340">https://github.com/rust-lang/compiler-team/issues/340</a></p>



<a name="209398245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209398245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209398245">(Sep 08 2020 at 14:58)</a>:</h4>
<p>I am currently working on this but it probably will take a few more weeks until this is available on nightly</p>



<a name="209398343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209398343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209398343">(Sep 08 2020 at 14:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue/near/209398177">said</a>:</p>
<blockquote>
<p>you already found the hackmd, here's the relevant compiler mcp: <a href="https://github.com/rust-lang/compiler-team/issues/340">https://github.com/rust-lang/compiler-team/issues/340</a></p>
</blockquote>
<p>That was <a href="#narrow/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue/near/209380797">found as well</a> :-)</p>



<a name="209398389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209398389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209398389">(Sep 08 2020 at 14:58)</a>:</h4>
<p>ah <span class="user-mention silent" data-user-id="281757">Jubilee</span> abready mentioned this <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span></p>



<a name="209398727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209398727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209398727">(Sep 08 2020 at 15:00)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> I will ask — is <code>()</code> any kind of special thing for that syntax, or is it just short notation? Would</p>
<div class="codehilite"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span>:
<span class="p">{</span><span class="w"></span>
</code></pre></div>


<p>work the same?</p>



<a name="209398789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209398789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209398789">(Sep 08 2020 at 15:00)</a>:</h4>
<p>yeah, <code>()</code> is just the most boring type we have</p>



<a name="209398852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209398852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209398852">(Sep 08 2020 at 15:00)</a>:</h4>
<p>so <code>[u8; N - 1]</code> works the same, as long as the given anonymous constant is part of the public signature</p>



<a name="209419038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209419038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209419038">(Sep 08 2020 at 17:35)</a>:</h4>
<p><code>where [u8; N-1]: Sized</code> (or <code>where [u8; N-1]: ?Sized</code>) looks less odd and is compatible with current syntax.</p>



<a name="209420563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209420563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209420563">(Sep 08 2020 at 17:47)</a>:</h4>
<p>true, that seems slightly cleaner than just <code>[u8; N - 1]:,</code></p>



<a name="209424314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209424314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209424314">(Sep 08 2020 at 18:18)</a>:</h4>
<blockquote>
<p>and is compatible with current syntax</p>
</blockquote>
<p>The proposal syntax is already compatible in Rust 1.46 <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span> </p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">kenny</span><span class="p">()</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[();</span><span class="w"> </span><span class="mi">4</span><span class="p">]</span>: <span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="209424556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209424556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209424556">(Sep 08 2020 at 18:20)</a>:</h4>
<p>But I whole-heartedly agree with having something on the RHS. My poor parser in my brain walks off the end otherwise.</p>



<a name="209425099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209425099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209425099">(Sep 08 2020 at 18:24)</a>:</h4>
<p>of the prelude, <code>Eq</code> wins for golfing</p>



<a name="209426450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209426450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209426450">(Sep 08 2020 at 18:36)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Wf</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Wf</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span>: <span class="nc">Wf</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="209426944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209426944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209426944">(Sep 08 2020 at 18:41)</a>:</h4>
<p>Alternatively, since trait conjunction is written <code>Trait1 + Trait2</code>, perhaps it should be <code>[(), N - 1]: 0</code></p>



<a name="209427390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209427390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209427390">(Sep 08 2020 at 18:44)</a>:</h4>
<p>I was thinking about a <code>WellFormed</code> or <code>Exists</code> trait like that, but then realized it'd want to be in the stdlib anyway, and then it's not <em>that</em> different from <code>: ?Sized</code>.</p>



<a name="209427475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209427475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209427475">(Sep 08 2020 at 18:45)</a>:</h4>
<p><code>[u8; 4]: ?Sized</code> threw me for a loop though, since it seems like it is claiming that the array is unsized</p>



<a name="209428157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209428157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209428157">(Sep 08 2020 at 18:51)</a>:</h4>
<p>True.</p>



<a name="209431017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209431017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209431017">(Sep 08 2020 at 19:14)</a>:</h4>
<blockquote>
<p>The proposal syntax is already compatible in Rust 1.46 </p>
</blockquote>
<p>heh TIL. seems introduced since 1.16</p>



<a name="209434158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209434158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209434158">(Sep 08 2020 at 19:40)</a>:</h4>
<p>Curiosity: is <code>[u32; N]</code> also a bound of <code>N &lt;= usize::MAX/4</code>?</p>
<p>(Or even <code>isize::MAX/4</code>, given object size restrictions from <code>offset</code>?)</p>



<a name="209434356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209434356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209434356">(Sep 08 2020 at 19:42)</a>:</h4>
<p>no, it accepts <code>[u32; usize::MAX]</code></p>



<a name="209434987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209434987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209434987">(Sep 08 2020 at 19:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue/near/209434158">said</a>:</p>
<blockquote>
<p>is <code>[u32; N]</code> also a bound of <code>N &lt;= usize::MAX/4</code>?</p>
</blockquote>
<p>Double curiosity: I don't know how to parse this sentence. I see you got an answer, but I still don't get the question. :-)</p>



<a name="209435304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Braden Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435304">(Sep 08 2020 at 19:50)</a>:</h4>
<p>Logically, you could only fit <code>usize::MAX/4</code> u32s in memory, as each takes 4 bytes of space. Which I presume is the context of the question.</p>



<a name="209435306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435306">(Sep 08 2020 at 19:50)</a>:</h4>
<p><code>[u32; usize::MAX]</code> is not a valid type -- it's too big to exist.  So I was wondering if the const generics bound cared about that part.  (If it did, that would be another reason for <code>[(); N]</code> instead of <code>[SomethingNotZeroSized; N]</code>.)</p>



<a name="209435354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435354">(Sep 08 2020 at 19:51)</a>:</h4>
<p>Ah, I didn't even notice the switch from <code>u32</code> and <code>usize</code>. That would have helped slightly.</p>



<a name="209435542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435542">(Sep 08 2020 at 19:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue/near/209435306">said</a>:</p>
<blockquote>
<p>If it did, that would be another reason for <code>[(); N]</code> instead of <code>[SomethingNotZeroSized; N]</code>.</p>
</blockquote>
<p>Why is that? If my function took in / returned <code>SomethingNotZeroSized</code>, wouldn't I rather get those failures?</p>



<a name="209435584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435584">(Sep 08 2020 at 19:53)</a>:</h4>
<p>you might want those failures, but you won't get them (as of right now)</p>



<a name="209435746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435746">(Sep 08 2020 at 19:54)</a>:</h4>
<blockquote>
<p><code>[u32; usize::MAX]</code> is not a valid type -- it's too big to exist</p>
</blockquote>
<p>Which definition of "valid" is in use here? <code>fn x(_: &amp;[u32; usize::MAX]) {}</code> and <code>fn x(_: [u32; usize::MAX]) {}</code> compile (without calling them, for the reasons you stated).</p>



<a name="209435857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435857">(Sep 08 2020 at 19:55)</a>:</h4>
<p><code>fn x(_: [u32; usize::MAX]) {}</code> -- this surprises me -- are we wrapping in the stack frame?!?</p>



<a name="209435928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435928">(Sep 08 2020 at 19:56)</a>:</h4>
<p>I guess it will be passed by-ref, never localized?</p>



<a name="209435977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435977">(Sep 08 2020 at 19:56)</a>:</h4>
<p>the functions have to hit codegen</p>



<a name="209435980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209435980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209435980">(Sep 08 2020 at 19:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="138448">cuviper</span> <a href="#narrow/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue/near/209435584">said</a>:</p>
<blockquote>
<p>you might want those failures, but you won't get them (as of right now)</p>
</blockquote>
<p>Sure, but I was reading <span class="user-mention" data-user-id="125270">@scottmcm</span>'s point as "you might get an error, so avoid that error by using <code>()</code> instead" but I don't see <em>why</em> you'd want to avoid that error, since the types can never really exist.</p>



<a name="209436007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209436007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209436007">(Sep 08 2020 at 19:56)</a>:</h4>
<p>ah, yes, if you make that a <code>pub fn</code>, playground says:</p>
<div class="codehilite"><pre><span></span><code>error: the type `[u32; 18446744073709551615]` is too big for the current architecture
</code></pre></div>



<a name="209436627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209436627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209436627">(Sep 08 2020 at 20:02)</a>:</h4>
<p>FWIW, 64-bit targets are actually limited to <code>1 &lt;&lt; 47</code> bytes right now<br>
<a href="https://github.com/rust-lang/rust/blob/c59199efca5856cdf810919fbf9b5bce32dc4523/compiler/rustc_target/src/abi/mod.rs#L179-L197">https://github.com/rust-lang/rust/blob/c59199efca5856cdf810919fbf9b5bce32dc4523/compiler/rustc_target/src/abi/mod.rs#L179-L197</a></p>



<a name="209436743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209436743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209436743">(Sep 08 2020 at 20:03)</a>:</h4>
<p>no petabyte arrays here!</p>



<a name="209437219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209437219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209437219">(Sep 08 2020 at 20:06)</a>:</h4>
<p>So it's not really that the _type_ is (in)valid, as this definitely relies on the target.</p>



<a name="209437332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209437332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209437332">(Sep 08 2020 at 20:07)</a>:</h4>
<p>so one implication is that even <code>[u8; N]</code> would be more limited than <code>[(); N]</code>, if the max were checked at the type level</p>



<a name="209437423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209437423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209437423">(Sep 08 2020 at 20:08)</a>:</h4>
<p>Right, as we <em>can</em> have <code>[(); usize::MAX]</code> on any target.</p>



<a name="209437791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209437791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209437791">(Sep 08 2020 at 20:10)</a>:</h4>
<p>But I'd still circle back to my point that if the type system checked that, then you'd <em>want</em> that to be reported earlier. Kind like pre-/post- monomorphization errors.</p>
<p>One thing I <strong>am</strong> assuming is that this is all for actual arrays. If we are talking about using arrays only as a vehicle to express bounds for for other usages of const generics...</p>



<a name="209437906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209437906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209437906">(Sep 08 2020 at 20:12)</a>:</h4>
<p>But that seems to fall apart as soon as we don't have <code>usize</code>:</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">whatever</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">const</span><span class="w"> </span><span class="kt">u8</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ???</span>
</code></pre></div>



<a name="209438008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438008">(Sep 08 2020 at 20:12)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">struct</span> <span class="nc">Wf</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">u8</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">whatever</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">T</span>: <span class="kt">u8</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Wf</span><span class="o">&lt;</span><span class="n">expr_using_T</span><span class="o">&gt;</span>: <span class="o">?</span><span class="nb">Sized</span><span class="p">,</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="209438215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438215">(Sep 08 2020 at 20:14)</a>:</h4>
<p>about checking arrays to be less than <code>1 &lt;&lt; 47</code> elements long, I am somewhat torn but personally think it is slightly better to not check this as part of the type system and emit errors during monomorphization here</p>



<a name="209438238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438238">(Sep 08 2020 at 20:14)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">struct</span> <span class="nc">Wf</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="nc">T</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
</code></pre></div>


<p>I thought I saw you closed a PR that would allow that ^ ?</p>



<a name="209438333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438333">(Sep 08 2020 at 20:15)</a>:</h4>
<p>i think you mixed something up there, we merged a PR that explicitly forbid that <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="209438366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438366">(Sep 08 2020 at 20:15)</a>:</h4>
<p>so this would need a new struct for every new type</p>



<a name="209438463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438463">(Sep 08 2020 at 20:16)</a>:</h4>
<p>the idea is that when we want to actually stabilize this/we have a working version of it, we can add these bounds directly, without needing a type</p>



<a name="209438533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438533">(Sep 08 2020 at 20:16)</a>:</h4>
<p>but for that we have to add new syntax -&gt; <a href="https://www.waltons.co.uk/_imagesWT/products/2018-SI-001-001-0011%20%281%29.jpg">https://www.waltons.co.uk/_imagesWT/products/2018-SI-001-001-0011%20%281%29.jpg</a></p>
<div class="message_inline_image"><a href="https://www.waltons.co.uk/_imagesWT/products/2018-SI-001-001-0011%20%281%29.jpg"><img src="https://www.waltons.co.uk/_imagesWT/products/2018-SI-001-001-0011%20%281%29.jpg"></a></div>



<a name="209438642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438642">(Sep 08 2020 at 20:17)</a>:</h4>
<p>Oh, absolutely.</p>



<a name="209438940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Const%20generics%20math%20tracking%20issue/near/209438940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Const.20generics.20math.20tracking.20issue.html#209438940">(Sep 08 2020 at 20:20)</a>:</h4>
<p>I appreciate the meta-ness of not agreeing on which emoji to represent "bikeshed"</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>